/**
 * 
 */
package org.log4jeditor.xml.editor.contentassist;

import java.util.List;

import junit.framework.Assert;

import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.ITypeHierarchy;
import org.eclipse.jdt.internal.core.JavaProject;
import org.junit.Before;
import org.junit.Test;
import org.log4jconfig.xml.editor.utils.JdtUtils;
import org.log4jeditor.xml.editor.AbstractUITestCase;
import org.log4jeditor.xml.editor.DirtiesProjectFiles;

/**
 * @author Xi
 * 
 */
@SuppressWarnings("restriction")
public class TypeHierarchyTestCase extends AbstractUITestCase{

	@Before
	public void setup() throws Exception {
		setupEditorConfiguration("log4j-hierarchy.xml");
	}
	
	@Test
	@DirtiesProjectFiles
	public void testRetrieveAppenderHierarchy() throws Exception {
		Assert.assertNotNull("Project not found", javaProject.getProject());
		Assert.assertTrue("Project is not a JavaProject", JavaProject
				.hasJavaNature(javaProject.getProject()));
		Assert.assertNotNull("JavaProject not found", javaProject);
		
		IType type = JdtUtils.getTypeFromCurrentProject(javaProject, "org.apache.log4j.Appender");
		Assert.assertNotNull("Type not found", type);
		ITypeHierarchy hierarchy = JdtUtils.getTypeHierarchy(javaProject, type);
		Assert.assertNotNull("Type not found", hierarchy);
		List<String> values = JdtUtils.getClassesFromTypeHierarchy(javaProject, type,
				hierarchy);
		Assert.assertTrue("No values returned", values.size() > 0);
		
		
	}

}
